package cn.remexs.doris.geo.udf;


import cn.remexs.doris.geo.GeoUtils;
import org.apache.hadoop.hive.ql.exec.UDF;

/**
 * 政通墨卡托坐标转百度
 */
public class ZtToBd09 extends UDF {

    public String evaluate(Double lon, Double lat) {
        if (null == lon || null == lat) return null;
        double[] wgs84 = GeoUtils.mercatorToLonLat(lon, lat, true);
        double[] gcj02 = GeoUtils.wgs84ToGcj02(wgs84[0], wgs84[1]);
        double[] bd09 = GeoUtils.gcj02ToBd09(gcj02[0], gcj02[1]);
        return GeoUtils.buildWkt(bd09[0], bd09[1]);
    }
}
